package com.gosophia.govDoc.weboffice;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.gosophia.govDoc.weboffice.service.WebOfficeServer;


/**
 * Servlet implementation class WebOfficeServlet
 */
 
public class OfficeServer extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static final String CONTENT_TYPE = "text/html; charset=GBK";
	
 
	private WebOfficeServer webOfficeServer  ;
	
    /**
     * @see HttpServlet#HttpServlet()
     */
    public OfficeServer() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
//	@Override
//    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		 
//	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
//	@Override
//    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		 
//	}

    /* (non-Javadoc)
     * @see javax.servlet.http.HttpServlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
     */
    @Override
    public void service(HttpServletRequest req, HttpServletResponse res)
            throws ServletException, IOException {
        
        WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
       
        webOfficeServer = (WebOfficeServer) wac.getBean("webOfficeServer");
        res.setContentType(CONTENT_TYPE); 
        webOfficeServer.ExecuteRun(req, res);   
        
    }
	

}
